﻿using BLevy.Entidad;
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BLevy.UI
{
    public partial class frmCuponesSalidaReporte : Form
    {
        private IList<CobradorCupon> cobradorCuponL = new List<CobradorCupon>();

        public frmCuponesSalidaReporte(IList<CobradorCupon> cc)
        {
            cobradorCuponL = cc;
            InitializeComponent();
        }

        private void frmCuponesSalidaReporte_Load(object sender, EventArgs e)
        {
            try
            {
                var query = (from fila in cobradorCuponL
                             select new
                             {
                                 APELLIDO_COBRADOR = fila.cobrador.apellido,
                                 NOMBRES_COBRADOR = fila.cobrador.nombres,
                                 FECHA_SALIDA = fila.fecha,
                                 NUMERO_CUPON = fila.cupon.numero,
                                 APELLIDO_TITULAR = fila.cupon.socio.apellido,
                                 NOMBRES_TITULAR = fila.cupon.socio.nombres,
                                 IMPORTE = fila.cupon.total

                             }).ToList();

                ReportDataSource rds = new ReportDataSource();
                rds = new ReportDataSource("DataSet1", query);

                this.reportViewer1.LocalReport.ReportEmbeddedResource = "BLevy.UI.Reportes.CuponesSalidaReporte.rdlc";

                this.reportViewer1.LocalReport.DataSources.Add(rds);
                this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void reportViewer1_Print(object sender, ReportPrintEventArgs e)
        {
            var printerSettings = new PrinterSettings();

            printerSettings.Copies = 2;
            printerSettings.Collate = false;

            this.reportViewer1.PrinterSettings.Copies = 2;
            this.reportViewer1.PrinterSettings.Collate = false;

        }
    }
}
